import { getQARecycle,restoreQAJson,removeQAForeverJson,clearQARecycleJson } from '@/services/knowledgemanagement';

export default {
  namespace:'versiontwo',

  state: {
  
  },
  effects: {
    *fetch({ payload, callback }, { call, put }) {  
      const response = yield call(getQARecycle, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchb({ payload, callback }, { call, put }) {
      const response = yield call(restoreQAJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchc({ payload, callback }, { call, put }) { 
      const response = yield call(removeQAForeverJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchd({ payload, callback }, { call, put }) { 
        const response = yield call(clearQARecycleJson, payload);
        if (response) {
          if (callback && typeof callback === 'function') {
            callback(response);
          }
          yield put({
            type: 'save',
            payload: response,
          });
        }
      },
    
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
       
      };
    },
  },
};
